/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import Server.BUS.StringUlti;
import Server.DTO.UpdateNoWhereQuery;
import org.junit.*;
import static org.junit.Assert.*;

/**
 *
 * @author Trung
 */
public class UpdateNoWhereQueryTest {
    
    public UpdateNoWhereQueryTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }
    
    @Before
    public void setUp() {
    }
    
    @After
    public void tearDown() {
    }

    @Test
    public void testUpdateNoWhereQueryContructor1() {
        // TODO review the generated test code and remove the default call to fail.
        String queryString = "UPDATE TableA SET id = 2, name = \"abc\"";
        queryString = StringUlti.formatString(queryString);
        
        UpdateNoWhereQuery update = new UpdateNoWhereQuery(queryString);
        
        assertTrue(update.queryString.equalsIgnoreCase(queryString));
        assertTrue(update.keyWord.equalsIgnoreCase("UPDATE_NOWHERE"));
        assertTrue(update.setString.equalsIgnoreCase("id = 2, name = \"abc\""));
        assertTrue(update.updateString.equalsIgnoreCase("TableA"));
    }
    
    @Test
    public void testUpdateNoWhereQueryContructor2() {
        // TODO review the generated test code and remove the default call to fail.
        String queryString = "   UPDATE     TableA SET     id = 2, name = \"abc\"     ";
        queryString = StringUlti.formatString(queryString);
        
        UpdateNoWhereQuery update = new UpdateNoWhereQuery(queryString);
        
        assertTrue(update.queryString.equalsIgnoreCase(queryString));
        assertTrue(update.keyWord.equalsIgnoreCase("UPDATE_NOWHERE"));
        assertTrue(update.setString.equalsIgnoreCase("id = 2, name = \"abc\""));
        assertTrue(update.updateString.equalsIgnoreCase("TableA"));
    }
}
